<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="base.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>BBS-论坛注册系统</title>
		<link href="styles/style.css" rel="stylesheet" type="text/css" />
		<style type="text/css">
			.required{
				width:200px;
				height:30px;
				line-height:30px;
			}
		</style>
		<script type="text/javascript" src="script/jquery.js">
</script>
		<script type="text/javascript">
$(document).ready(function(){
				$("form :input.required").each(function(){
					 var $required = $('<strong class="high">*</strong>');
					$(this).parent().append($required);
				});
				$("form :input").blur(function(){
					var $parent = $(this).parent();
					$parent.find(".formtips").remove();
						//验证用户名
					if($(this).is("#name")){
						if(this.value == "" ||  this.value.length <6){
							var errorMsg = '至少输入6个字符';
							$parent.append('<span class = "formtips onError">'+errorMsg+'</span>');
						}else{
							var okMsg = '输入正确';
							$parent.append('<span class = "formtips onError">'+okMsg+'</span>');
						}
					}
					//验证邮箱
					if($(this).is("#email")){
						if(this.value == "" || this.value != "" && !/.+@.+\.[a-zA-Z]{2,4}$/.test(this.value)){
							var errorMsg = '请输入正确的邮件格式';
							$parent.append('<span class = "formtips onError">'+errorMsg+'</span>');
						}else{
							var okMsg = '输入正确';
							$parent.append('<span class = "formtips onRight">'+okMsg+'</span>');
						}
					}
					if($(this).is("#checkcode")){
						if(this.value == "" || this.value != "" && this.value.length < 6){
							var errorMsg = '验证码至少6个字符组成';
							$parent.append('<span class = "formtips onError">'+errorMsg+'</span>');
						}else{
							var okMsg = '输入正确';
							$parent.append('<span class = "formtips onRight">'+okMsg+'</span>');
						}
					}
				});
			$("#btn_update").click(function(){
				$("form :input.required").trigger("blur");
				var numError = $("form .onError").length-1;
				if(numError){
					return false;
				}
			});
	});
		</script>
	</head>

	<body>
		<div class="container">
		<%@include file="template/header.jsp"%>
			<div class="center">
			<%@ include file="template/msg.file" %>
				<div class="box">
					<div class="size1">
						<h3 class="ico1">
							用户中心
						</h3>
						<form action="user!update" method="post">
						<input type="hidden" name="id" value="${user.id }"/>
							<table>
								<tbody>
									<tr id="err_tr" style="display: none">
										<th>
											&nbsp;
										</th>
										<td width="26%" id="err_text" style="color: red">
											用户名或密码错误，请检查
										</td>
									</tr>
									<tr>
										<th>
											用户名
										</th>
										<td>
											<input class="required" id="name" name="name" value="${user.name }" type="text"
												style="padding-top: 4px" />
										</td>
									</tr>
									<tr>
										<th>
											电子邮箱：
										</th>
										<td>
											<input class="required" id="email" name="email" value="${user.email }" type="text" />
										</td>
									</tr>
									<tr>
										<th>
											验证码：
										</th>
										<td>
											<img src="jcaptcha.jpg" alt="" />
											<input type="text" id="checkcode" class="required" name="checkcode"
												style="float: left" />
										</td>
									</tr>
									<tr>
										<th>
										</th>
										<td class="btnarea">
											<c:remove var="user" scope="request" />
											<input type="submit" id="btn_update" class="btnstyle" value="修改资料" />
										</td>
									</tr>
								</tbody>
							</table>
						</form>
					</div>
					<div class="size2">
						<img src="images/img_ldbyy.jpg" />
					</div>
				</div>
			</div>
			<%@include file="template/footer.jsp"%>
		</div>
	</body>
</html>
